#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Production/Production.WebApi/Production.WebApi.csproj", "Production/Production.WebApi/"]
COPY ["Swimj/Swimj.AspNetCore/Swimj.AspNetCore.csproj", "Swimj/Swimj.AspNetCore/"]
COPY ["Swimj/Swimj.CommonLib/Swimj.CommonLib.csproj", "Swimj/Swimj.CommonLib/"]
COPY ["Swimj/Swimj.Core/Swimj.Core.csproj", "Swimj/Swimj.Core/"]
COPY ["Production/Production.ApplicationLib/Production.ApplicationLib.csproj", "Production/Production.ApplicationLib/"]
COPY ["Production/Production.CommonLib/Production.CommonLib.csproj", "Production/Production.CommonLib/"]
COPY ["BaseData/BaseData.CommonLib/BaseData.CommonLib.csproj", "BaseData/BaseData.CommonLib/"]
COPY ["Production/Production.DomainLib/Production.DomainLib.csproj", "Production/Production.DomainLib/"]
COPY ["Swimj/Swimj.DomainLib/Swimj.DomainLib.csproj", "Swimj/Swimj.DomainLib/"]
COPY ["Swimj/Swimj.DataCore/Swimj.DataCore.csproj", "Swimj/Swimj.DataCore/"]
COPY ["Production/Production.InfrastructureLib/Production.InfrastructureLib.csproj", "Production/Production.InfrastructureLib/"]
COPY ["Swimj/Swimj.InfrastructureLib/Swimj.InfrastructureLib.csproj", "Swimj/Swimj.InfrastructureLib/"]
RUN dotnet restore "Production/Production.WebApi/Production.WebApi.csproj"
COPY . .
WORKDIR "/src/Production/Production.WebApi"
RUN dotnet build "Production.WebApi.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Production.WebApi.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Production.WebApi.dll"]